import 'package:craze/common/index.dart';
import 'package:craze/services/hive_service.dart';
import 'package:craze/services/service_locator.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // 初始化Hive
  await HiveService.init();

  // 初始化服务定位器
  await ServiceLocator.init();

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(414, 896),
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (_, child) {
        return MaterialApp.router(
          title: 'Craze',
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: MyColors.blue),
            textTheme: Typography.englishLike2018.apply(fontSizeFactor: 1.sp),
            fontFamily: GoogleFonts.mochiyPopOne().fontFamily,
          ),
          routerConfig: AppRouter.router,
          debugShowCheckedModeBanner: false,
        );
      },
    );
  }
}
